﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace Studentium.Util
  {
  class Log
    {
    static Log()
      {
      Directory.CreateDirectory( "logs" );
      }

    public static void log( string msg )
      {
      log( msg, "INFO" );
      }

    public static void log( string msg, string level )
      {
      string filename = DateTime.Now.ToLongDateString();
      StreamWriter writer = File.AppendText( "logs/" + filename + ".log" );
      writer.WriteLine( DateTime.Now.ToLongTimeString() + " " + level + " : " + msg );
      writer.Close();
      }

    public static void log( Exception ex )
      {
      log( "", ex);
      }

    public static void log( string msg, Exception ex )
      {
      log(msg + " " + ex.Message + " " + ex.StackTrace, "EXCEPTION");
      }
    }
  }
